package com.scheduling.user.mapper;

import com.scheduling.user.entity.User;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

// UserMapper 接口 - 添加删除用户的方法
@Mapper
public interface UserMapper {

    @Select("SELECT * FROM user WHERE username = #{username}")
    User findByUsername(String username);

    @Select("SELECT * FROM user WHERE user_id = #{userId}")
    User findByUserId(String userId);

    @Insert("INSERT INTO user (user_id, username, password, create_time) " +
            "VALUES (#{userId}, #{username}, #{password}, #{createTime})")
    int insertUser(User user);

    @Select("SELECT COUNT(*) FROM user WHERE username = #{username}")
    int countByUsername(String username);

    @Delete("DELETE FROM user WHERE user_id = #{userId}")
    int deleteByUserId(String userId);

    @Delete("DELETE FROM user WHERE username = #{username}")
    int deleteByUsername(String username);
}